<template>
  <div class="community">
    <div class="community-nav">
      <router-link
        :to="{ name: 'communityTask' }"
        :class="{ active: curType === 1 }"
        @click.native="changeNavId(1)"
        >作业
        <p v-if="curType == 1"></p>
      </router-link>
      <router-link
        :to="{ name: 'communityAnswer' }"
        :class="{ active: curType === 2 }"
        @click.native="changeNavId(2)"
        >问答
        <p v-if="curType == 2"></p>
      </router-link>
      <router-link
        :to="{ name: 'communityWorks' }"
        :class="{ active: curType === 3 }"
        @click.native="changeNavId(3)"
        >作品
        <p v-if="curType == 3"></p>
      </router-link>
      <router-link
        :to="{ name: 'communityDraw' }"
        :class="{ active: curType === 4 }"
        @click.native="changeNavId(4)"
        >指绘
        <p v-if="curType == 4"></p
      ></router-link>
    </div>
    <router-view></router-view>
  </div>
</template>

<script>
export default {
  name: "CommunityVue",
  data() {
    return {
      curType: 1,
    };
  },

  methods: {
    changeNavId(id) {
      this.curType = id;
    },
  },
};
</script>

<style lang="scss" scoped>
*{
  margin: 0;
  padding: 0;
}
.community-nav {
  height: 48px;
  // background-color: aqua;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-bottom: 1px solid #eee;
  margin-top: -4px;
  .active {
    color: #0060DF;
  }
}
a {
  display: block;
  height: 48px;
  line-height: 48px;
  position: relative;
  p {
    width: 100%;
    height: 3px;
    background-color: #0060DF;
    position: absolute;
    bottom: 0;
  }
}

// a {
//   &.router-link-exact-active {
//     color: blue;
//   }
// }
</style>
